package com.zhuanzhuan.hero.user.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * @ClassName LabelStateEnum
 * @Description
 * @Author hanjunjun
 * @Date 2024/7/1 11:45
 */
@Getter
public enum LabelStateEnum {

    INVALID(0, "未启用"),
    EFFECTIVE(1, "已启用")
    ;

    private final Integer code;

    private final String name;

    LabelStateEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getNameByCode(Integer code) {
        return Arrays.stream(LabelStateEnum.values())
            .filter(anEnum -> code.equals(anEnum.getCode()))
            .findFirst()
            .orElseThrow(() -> new IllegalArgumentException("code不存在枚举"))
            .getName();
    }
}
